import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getCategoryAPI } from '@/apis/Layout.js'

export const useCategoryStore = defineStore('category', () => {
    const categoryList = ref([])
    const categoryTree = ref([])
    const getCategory = async () => {
        let res = await getCategoryAPI()
        console.log('res: getCategoryAPI 分类', res);
        // categoryList.value = getCategoryList(res.data || [], true)
        categoryList.value = res.data
        console.log('categoryList.value: ', categoryList.value);
        categoryTree.value = res.data
        // console.log('categoryTree.value: ', categoryTree.value);
    }

    return {
        categoryList,
        categoryTree,
        getCategory
    }
})
